home *** CD-ROM | disk | FTP | other *** search
- \ More stuff for standard Forth BLOCKs
-
- forth definitions
- nuser block-file
- nuser block-input-file
-
- : !files (s fcb -- ) dup block-file ! block-input-file ! ;
- \ : default (s -- ) [ sys ] open-default-file !files ;
-
- : file? (s -- ) block-file @ .file ;
- : switch (s -- )
- block-file @ block-input-file @ block-file ! block-input-file ! ;
- : capacity (s -- n )
- [ sys ] block-file @ file#blocks ;
-
- : buffer (s n -- a ) block-file @ (buffer) ;
- : block (s n -- a ) block-file @ (block) ;
- : flush (s -- )
- save-buffers 0 block drop empty-buffers ;
- : in-block (s n -- a ) block-input-file @ (block) ;
- : view# (s -- addr ) block-file @ 40 + ;
-
- : use-file ( str -- )
- [ sys ] open-file !files
- ;
- : using \ filename ( -- )
- bl word use-file
- ;
- \ block-load interprets Forth source code from a block buffer.
- \ This works by copying the block into the file buffer, and assumes
- \ that the file buffer is at least as big as a block.
-
- : block-fwrite ( addr count l.byteno fd -- count ) \ Does nothing
- drop ldrop nip
- ;
- : block-flen ( fd -- size ) drop b/buf ;
- : load ( block# -- )
- get-fd
- block bfbase @ b/buf cmove ( )
- bfbase @ b/buf + ( end )
- dup bflimit ! dup bfend ! bftop !
-
- 0 fid !
- modify fmode !
- ['] nullread fread !
- ['] block-fwrite fwrite !
- ['] drop fclose !
- ['] noop falign !
- ['] block-flen flen !
-
- file @ dup >r (load r> close
- ;
- : list ( scr# -- )
- ." Screen " . cr
- dup block b/buf bounds
- do i c/l type cr c/l +loop
- ;
-
- \ Backslash (comment to end of line) for blocks:
- \ hex
- \ : \ \ rest-of-line ( -- )
- \ in-file @ file !
- \ bfcurrent @ bfbase @ - 63 + 63 not and
- \ bfcurrent !
- \ ;
-